// UpdateCallback100.h

#ifndef __UPDATE_CALLBACK100_H
#define __UPDATE_CALLBACK100_H

#include "Common/COM/IPassword.h"

#include "Common/Agent/IFolderArchive.h"

#include "../../ProgressDialog2.h"

class ATL_NO_VTABLE CUpdateCallback100Imp:
	public Common::Agent::IFolderArchiveUpdateCallback,
	public ICryptoGetTextPassword2,
	public ICryptoGetTextPassword,
	public IArchiveOpenCallback,
	public ICompressProgressInfo,
	public CComObjectRootEx<CComSingleThreadModel>
{
	bool _passwordIsDefined;
	CString _password;
	UINT64 _numFiles;
public:
	CProgressDialog2* ProgressDialog;

	CUpdateCallback100Imp(): ProgressDialog(0) {}

	BEGIN_COM_MAP(CUpdateCallback100Imp)
		COM_INTERFACE_ENTRY(Common::Agent::IFolderArchiveUpdateCallback)
		COM_INTERFACE_ENTRY(ICryptoGetTextPassword2)
		COM_INTERFACE_ENTRY(ICryptoGetTextPassword)
		COM_INTERFACE_ENTRY(IArchiveOpenCallback)
		COM_INTERFACE_ENTRY(ICompressProgressInfo)
	END_COM_MAP()



	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		_passwordIsDefined = false;
		_numFiles = 0;
		return S_OK;
	}

	void FinalRelease()
	{

	}

	//INTERFACE IProgress
	STDMETHOD(SetTotal)(UINT64 total);
	STDMETHOD(SetCompleted)(const UINT64* completeValue);

	//INTERFACE IArchiveOpenCallback
	STDMETHOD(SetTotal)(const UINT64* files, const UINT64* bytes);
	STDMETHOD(SetCompleted)(const UINT64* files, const UINT64* bytes);

	//INTERFACE IFolderArchiveUpdateCallback
	STDMETHOD(CompressOperation)(const wchar_t* name) ;
	STDMETHOD(DeleteOperation)(const wchar_t* name) ;
	STDMETHOD(OperationResult)(INT32 operationResult) ;
	STDMETHOD(UpdateErrorMessage)(const wchar_t* message) ;
	STDMETHOD(SetNumFiles)(UINT64 numFiles) ;

	STDMETHOD(SetRatioInfo)(const UINT64* inSize, const UINT64* outSize);

	STDMETHOD(CryptoGetTextPassword)(BSTR* password);
	STDMETHOD(CryptoGetTextPassword2)(INT32* passwordIsDefined, BSTR* password);

	void Init(bool passwordIsDefined, const CString &password)
	{
		_passwordIsDefined = passwordIsDefined;
		_password = password;
		_numFiles = 0;
	}
};

#endif
